package com.sctvcloud.longchang.ui.adapter.holder;

import android.content.Context;
import android.view.View;

import com.jiongbull.jlog.JLog;
import com.ruihang.generalibrary.ui.widget.CustomFontTextView;
import com.sctvcloud.longchang.R;
import com.sctvcloud.longchang.beans.TelInitialsBean;
import com.sctvcloud.longchang.beans.TelTitle;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 右侧字母索引
 */
public class LetterIndexHolder extends BaseAbsHolder<TelInitialsBean> implements View.OnClickListener {
    @BindView(R.id.letter_index)
    protected CustomFontTextView letterIndex;
    private OnLetterClickLister listener;
    private TelInitialsBean t;

    public LetterIndexHolder(Context context, View itemView, OnLetterClickLister listener) {
        super(context, itemView);
        itemView.setOnClickListener(this);
        this.listener = listener;
    }

    @Override
    protected void initInject() {
        ButterKnife.bind(this, itemView);
    }

    @Override
    public void setData(TelInitialsBean titles) {
        t = titles;
        letterIndex.setText(titles.getLetter());
        if (titles.isSelected()) {
            letterIndex.setTextColor(context.getResources().getColor(R.color.colorHomeText));
        } else {
            letterIndex.setTextColor(context.getResources().getColor(R.color.colorBlack22));
        }
        JLog.d("--letterIndex--titles.isSelected()="+titles.isSelected());
    }

    @Override
    public void onClick(View v) {
        if (null != listener) {
            listener.OnLetterClick(t);
        }
    }

    public interface OnLetterClickLister {
        void OnLetterClick(TelInitialsBean letter);
    }
}